# coding:utf-8

import itchat
import matplotlib
import matplotlib.pyplot as plt
itchat.auto_login(hotReload=True)
wxFriends = itchat.get_friends(update=True)
sex = []
for friend in wxFriends[1:]:
    sex.append(friend["Sex"])

print("微信好友数： ",len(sex))

labels = [u"空",u"男",u"女"]
null = sex.count(0)
male = sex.count(1)
female = sex.count(2)
result = [null,male,female]
zhfont1 = matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\simkai.ttf')
patches,l_text,p_text = plt.pie(result,labels=labels,autopct="%3.1ff %%",shadow=True,
        labeldistance=1.1,startangle=90,pctdistance=0.6)
for t in l_text:
    t.set_fontproperties(matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\simkai.ttf'))
plt.legend(loc="upper right",prop=zhfont1)
plt.show()
